﻿using System;
using System.Collections.Generic;
using System.Linq;

namespace CourseManager.Model.Data
{
	public class CourseDAO
	{
		/// <summary>
		/// 根据id查找User
		/// </summary>
		/// <param name="id">编号</param>
		/// <param name="courseId"></param>
		/// <returns></returns>
		public static View_Course FindById(String courseId, String tId)
		{
			DBEntity ent = new DBEntity();


			return (from course in ent.View_Course
					where course.courseId.Equals(courseId) &&
							course.tId.Equals(tId)
			        select course).FirstOrDefault();
		}

		public static Tab_Course FindByIdWithoutTName(String courseId, String tId)
		{
			DBEntity ent = new DBEntity();


			return (from _course in ent.Tab_Course
					where _course.courseId.Equals(courseId) &&
							_course.tId.Equals(tId)
					select _course).FirstOrDefault();
		}

		public static IEnumerable<Tab_Course> FindById(String courseId)
		{
			DBEntity ent = new DBEntity();


			return (from course in ent.Tab_Course
					where course.courseId.Equals(courseId)
					select course);
		}


		public static IEnumerable<Tab_Course> FindAll()
		{
			DBEntity ent = new DBEntity();

			return from course in ent.Tab_Course
			       select course;
		}
	}
}